#!/bin/bash


# define variable and use it
var="hello";
echo $var;
echo ${var};
printf "${var} world!\n";

## get length of a string
var=1234567890;
len=${#var};
echo length is $len;


# -- what is environment variable ?
# -- env vars are those not defined in current process, but
#    recieved from the parent process. look at this demo:

echo $HTTP_PROXY    # env variable
HTTP_PROXY=localhost:7890
export HTTP_PROXY # used to set the env vars
# now with execution of export command, HTTP_PROXY will
# be passed to all programs executed by this script.

# checking for super user 

## there're env vars called 'UID' it can be used to identifing
## the execute user of current script
if [ $UID -ne 0 ]; then # -ne is represent to "not equal to ..."
    echo Non root user. Please run as root
else 
    echo Root user 
fi
## the uid of super user is 0 constantly
#----------------------------------------

# function to prepend to envrioment variables

## make your apps be prepend to envrioment variable
export PATH=/opt/myapp/bin:$PATH
